'''
包含参数的进程函数
'''
from multiprocessing import Process
from time import sleep


# 创建带有参数的进程执行函数
def worker(sec, name):
    for i in range(3):
        sleep(sec)
        print('I am %s' % name)
        print('I am working...')


# 实例化进程对象传递参数
# process = Process(target=worker, args=(2, 'Ayer'))
process = Process(target=worker, kwargs={'sec': 2, 'name': 'Ayer'}, daemon=True)
# daemon 子进程随父进程结束而结束

# 启动进程（进程产生，运行绑定函数）
process.start()

sleep(4)
